package com.example.mapper;

import com.example.entity.SalesData;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface SalesDataMapper {
    @Select("SELECT * FROM sales_data LIMIT 10")
    List<SalesData> findSample();
    
    @Select("SELECT SUM(amount) as value, quarter as dimension FROM sales_data WHERE year = #{year} GROUP BY quarter ORDER BY quarter")
    List<Map<String, Object>> getSalesAmountByQuarter(int year);
    
    @Select("SELECT SUM(quantity) as value, quarter as dimension FROM sales_data WHERE year = #{year} GROUP BY quarter ORDER BY quarter")
    List<Map<String, Object>> getSalesQuantityByQuarter(int year);
    
    @Select("SELECT product_name as dimension, SUM(quantity) as value FROM sales_data WHERE year = #{year} GROUP BY product_name ORDER BY value DESC")
    List<Map<String, Object>> getProductQuantityRanking(int year);
}